package com.lzb.compressmaster.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.lzb.compressmaster.R;
import com.lzb.compressmaster.basic.ProviderMultiAdapter;
import com.lzb.compressmaster.bean.CommonBean;

public class FormatAdapter extends ProviderMultiAdapter<CommonBean> {

    public FormatAdapter() {
        addItemProvider(new FormatProvider());
    }

    private class FormatProvider extends BaseItemProvider<CommonBean> {
        @Override
        public int getItemViewType() {
            return ProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_format;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, CommonBean bean) {
            baseViewHolder.setText(R.id.tvFormatItemName, bean.getName());
            if (bean.isSelected()) {
                baseViewHolder.setBackgroundResource(R.id.tvFormatItemName, R.drawable.compress_mode_sel);
                baseViewHolder.setTextColor(R.id.tvFormatItemName, Color.parseColor("#FFFFFF"));
            } else {
                baseViewHolder.setBackgroundResource(R.id.tvFormatItemName, R.drawable.compress_mode_bg);
                baseViewHolder.setTextColor(R.id.tvFormatItemName, Color.parseColor("#333333"));
            }
        }
    }

}
